home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / amicad / arexx_english / karnaugh.amicad < prev    next >
Text File  |  1998-08-09  |  2KB  |  119 lines

  1. /* Create a table of Karnaugh
  2.    Version 1.01e, 9 août 1998, © R.Florac */
  3.  
  4. options results
  5.  
  6. signal on error
  7. signal on syntax
  8.  
  9. 'ASK("How many inputs?")'; nbe=result
  10. if nbe="" then exit
  11.  
  12. do i=1 to nbe
  13.     'ASK("Name of input 'i'")'; nomE.i=result
  14. end
  15.  
  16. 'ASK("Output name?")'; nomS=result
  17.  
  18. 'SETSCALE(0,1,1):ROTATE(0,0):SYMMETRY(0,0):DRAWMODE(1)'
  19.  
  20. nbcases=2**nbe
  21. nblignes=nbe%2
  22. nbcol=nbe-nblignes
  23.  
  24. c=(nbe-nbcol)*10+20
  25. l0=10+nbcol*15
  26. l1=l0+(2**nblignes)*30
  27. do col=1 to (2**nbcol)+1
  28.     select
  29.     when col=1 then 'DRAWMODE(2)'
  30.     when col=(2**nbcol)+1 then 'DRAWMODE(2)'
  31.     otherwise 'DRAWMODE(1)'
  32.     end
  33.     'MARK(DRAW('c+col*30','l0','c+col*30','l1'))'
  34.     col.col=c+col*30
  35. end
  36.  
  37. c0=(nbe-nbcol)*10+50
  38. c1=c0+((2**nbcol))*30
  39. do i=1 to (2**nblignes)+1
  40.     select
  41.     when i=1 then 'DRAWMODE(2)'
  42.     when i=(2**nblignes)+1 then 'DRAWMODE(2)'
  43.     otherwise 'DRAWMODE(1)'
  44.     end
  45.     'MARK(DRAW('c0','l0','c1','l0'))'
  46.     ligne.i=l0
  47.     l0=l0+30
  48. end
  49.  
  50. nbval=(2**nbcol)/2
  51. l0=10+nbcol*15
  52. pas=1
  53. do c=1 to nbcol
  54.     if c=nbcol then do
  55.     p=nbval+1
  56.     d=p+nbval
  57.     'MARK(DRAW('col.p','l0-c*10','col.d','l0-c*10'))'
  58.     end
  59.     else do
  60.     p=pas+1
  61.     do while p<=nbval*2
  62.         r=p+pas*2
  63.         'MARK(DRAW('col.p','l0-c*10','col.r','l0-c*10'))'
  64.         p=r+pas*2
  65.     end
  66.     pas=pas*2
  67.     end
  68. end
  69.  
  70. nbval=(2**nblignes)/2
  71. pas=1
  72. do l=1 to nblignes
  73.     if l=nblignes then do
  74.     p=nbval+1
  75.     d=p+nbval
  76.     'MARK(DRAW('col.1-10*l','ligne.p','col.1-10*l','ligne.d'))'
  77.     end
  78.     else do
  79.     p=pas+1
  80.     do while p<=nbval*2
  81.         r=p+pas*2
  82.         'MARK(DRAW('col.1-10*l','ligne.p','col.1-10*l','ligne.r'))'
  83.         p=r+pas*2
  84.     end
  85.     pas=pas*2
  86.     end
  87. end
  88.  
  89. 'ROTATE(0,3):DRAWMODE(1)'
  90. do i=1 to nblignes
  91.     if nomE.i="" then nomE.i='?'
  92.     'MARK(WRITE("'nomE.i'",'col.1-10*i+3','ligne.d+10'+TXHEIGHT("'nomE.i'")))'
  93.     c=c+15
  94. end
  95.  
  96. 'ROTATE(0,0)'
  97. d=(2**nbcol)+1
  98. do while i<=nbe
  99.     if nomE.i="" then nomE.i='?'
  100.     'MARK(WRITE("'nomE.i'",'col.d+5','ligne.1+4-10*(i-nblignes)'))'
  101.     i=i+1
  102. end
  103.  
  104. if nomS="" then nomS="?"
  105. d=d%2+1
  106. p=(2**nblignes)+1
  107. 'MARK(WRITE("'nomS'",'col.d'-TXWIDTH("'nomS'")/2,'ligne.p+15'))'
  108.  
  109. exit
  110.  
  111. syntax:
  112. erreur=RC
  113. 'MESSAGE("Script Karnaugh"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  114. exit
  115.  
  116. error:
  117. 'MESSAGE("Script Karnaugh"+CHR(10)+"Error in line 'SIGL'")'
  118. exit
  119.